package cn.edu.nwafu.core.controller.api;


import cn.edu.nwafu.common.result.R;
import cn.edu.nwafu.core.pojo.query.TicketInfoQuery;
import cn.edu.nwafu.core.pojo.vo.TicketInfoVo;
import cn.edu.nwafu.core.service.TicketInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhanghao
 * @since 2021-10-30
 */
@RestController
@Slf4j
@Api(tags = "机票管理")
@RequestMapping("/api/core/ticketInfo")
public class TicketInfoController {

    @Autowired
    private TicketInfoService ticketInfoService;

    @ApiOperation("查询用户订单")
    @PostMapping("listAll/{userId}")
    public R listAll(
            @ApiParam("查询用户id")
            @PathVariable Long userId,
            @ApiParam("用户查询条件")
            @RequestBody TicketInfoQuery ticketInfoQuery
    ) {

        List<TicketInfoVo> list = ticketInfoService.listTicketById(userId, ticketInfoQuery);

        if (list == null) {
            return R.error();
        }

        return R.ok().data("list", list);
    }

}

